<template>
  <el-card>
    <div class="box">
      <img :src="imageUrl" alt="" class="avatar" />
      <div class="bottom">
        <h3 class="title">{{ getTime() }}好呀 {{ userStore.nickname }}</h3>
        <p class="subtitle">欢迎来到BP二手房房价预测与分析</p>
        <p class="btitle"></p>
      </div>
    </div>
  </el-card>
  <!-- <div class="bottoms">
    <svg-icon name="welcome" width="600px" height="300px"></svg-icon>
  </div> -->
  <div class="main">
    <div class="left">
      <LeftChart />
    </div>
    <div class="center"></div>
    <div class="right">
      <RightChart />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { getTime } from '@/utils/time'
//引入用户相关的仓库,获取当前用户的头像、昵称
import useUserStore from '@/store/modules/user'
// 接口
import { reqAvatarAPI } from '@/api/user/index'

//获取存储用户信息的仓库对象
let userStore = useUserStore()

let imageUrl = ref('')

// 请求头像并获取资源
const init = async () => {
  const arr = userStore.avatar.split('/')
  const filename = arr[arr.length - 1]
  const response = await reqAvatarAPI(filename)
  imageUrl.value = URL.createObjectURL(response)
}

onMounted(() => {
  init()
})
</script>

<style scoped lang="scss">
.box {
  display: flex;

  .avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
  }

  .bottom {
    margin-left: 20px;

    .title {
      font-size: 30px;
      font-weight: 900;
      margin-bottom: 30px;
    }

    .subtitle {
      font-style: italic;
      color: skyblue;
      font-size: 22px;
    }
    .btitle {
      padding-top: 10px;
      color: rgb(151, 153, 154);
      font-size: 18px;
    }
  }
}
// .bottoms{
//   margin-top: 10px;
//   display: flex;
//   justify-content: center;
// }
.main {
  margin-top: 20px;
  display: flex;
  width: 100%;
  height: 500px;
  .left {
    flex: 1;
    height: 100%;
  }
  .center {
    flex: 0.025;
  }
  .right {
    flex: 1;
    height: 100%;
  }
}
</style>
